﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.ActiveRecord;
using Castle.Components.Validator;
using MiragePWF.NH.Validation;
using Wolfut.MirageEE.Kernal.Common;
using Wolfut.MirageEE.Domain.CommonUtilities;

namespace Wolfut.MirageEE.Domain.Common
{
    [ActiveRecord("EMPLOYEES")]
    public class Employee : PersistentObjectWithGuid
    {
        #region 职员编号
        [Property("EMPLOYEE_CODE")]
        [ValidateNonEmpty, ValidateLength(0, 100, "职员编号超长")]
        public virtual string EmployeeCode
        {
            get
            {
                return employeeCode;
            }
            set
            {
                employeeCode = value;
            }
        }
        private string employeeCode;
        #endregion

        #region 姓名
        [Property("EMPLOYEE_NAME")]
        [ValidateLength(0, 40, "姓名超长")]
        public virtual string EmployeeName
        {
            get
            {
                return employeeName;
            }
            set
            {
                employeeName = value;
            }
        }
        private string employeeName;
        #endregion

        #region 类型
        [Property("EMPLOYEE_TYPE")]
        [ValidateNonEmpty]
        public virtual EmployeeType EmployeeType
        {
            get
            {
                return employeeType;
            }
            set
            {
                employeeType = value;
            }
        }
        private EmployeeType employeeType;
        #endregion

        #region 佣金率
        [Property("SALARY_RATE")]
        [ValidateRangeEx(RangeValidationType.Decimal, 0.0, int.MaxValue, "佣金率必须大于0！")]
        public virtual decimal SalaryRate
        {
            get
            {
                return salaryRate;
            }
            set
            {
                salaryRate = value;
            }
        }
        private decimal salaryRate;
        #endregion

        #region 性别
        [Property("GENDER")]
        [ValidateNonEmpty]
        public virtual Sex Sex
        {
            get
            {
                return sex;
            }
            set
            {
                sex = value;
            }
        }
        private Sex sex;
        #endregion

        #region 生日
        [Property("BIRTHDAY")]
        public virtual DateTime Birthday
        {
            get
            {
                return birthday;
            }
            set
            {
                birthday = value;
            }
        }
        private DateTime birthday;
        #endregion

        #region Email
        [Property("EMAIL")]
        [ValidateEmail,ValidateLength(0,40,"Email超长")]
        public virtual string Email
        {
            get
            {
                return email;
            }
            set
            {
                email = value;
            }
        }
        private string email;
        #endregion

        #region 手机号码
        [Property("CELLPHONE")]
        [ValidateLength(0, 15, "手机号码超长")]
        public virtual string CellPhone
        {
            get
            {
                return cellPhone;
            }
            set
            {
                cellPhone = value;
            }
        }
        private string cellPhone;
        #endregion

        #region 备注
        [Property("备注")]
        [ValidateLength(0, 2000, "备注超长")]
        public virtual string Remarks
        {
            get
            {
                return remarks;
            }
            set
            {
                remarks = value;
            }
        }
        private string remarks;
        #endregion

        #region 允许短信查询
        [Property("ALLOW_CELLPHONE_QUERY")]
        [ValidateNonEmpty]
        public virtual bool AllowCellPhoneQuery
        {
            get
            {
                return allowCellPhoneQuery;
            }
            set
            {
                allowCellPhoneQuery = value;
            }
        }
        private bool allowCellPhoneQuery;
        #endregion

        #region 部门
        private Department department;

        [BelongsTo("DEPARTMENTS_ID")]        
        public virtual Department Department
        {
            get { return department; }
            set { department = value; }
        }
        #endregion

        #region 是否删除
        [Property("IS_DELETED")]
        [ValidateNonEmpty]
        public virtual bool IsDeleted
        {
            get
            {
                return isDeleted;
            }
            set
            {
                isDeleted = value;
            }
        }
        private bool isDeleted;
        #endregion
    }
}
